marker = createMarker(207.59340, -101.60632, 1005.25781, "cylinder", 2, 100, 0, 255, 0)
setElementData(marker, 'marker:data', {name='Przebieralnia', icon='shirt',size=1})

setElementInterior(marker, 15)
setElementDimension(marker, 2000)

function hit(el,md)
if not md or getElementType(el) ~= "player" then return end
    local q=exports["cmta-db"]:dbGet("select * from cmta_users where id=?", getElementData(el,"player:data").uid)   	
    triggerClientEvent(el,'cmta:przebieralnia:showGUI',resourceRoot,split(q[1].buyedskins, ","))
end
addEventHandler( "onMarkerHit", marker, hit)

addEvent("cmta:przebieralnia:kup", true)
addEventHandler("cmta:przebieralnia:kup", resourceRoot, function(id,price)
    local result=exports["cmta-db"]:dbGet("SELECT * FROM cmta_users WHERE id=?",getElementData(client,"player:data").uid)
    local skins = split(result[1]['buyedskins'], ',')
    local tableskins={}
    for i,v in pairs(skins) do
        table.insert(tableskins,v)
    end
    table.insert(tableskins,id)
    local data = getElementData(client,"player:data")
    data.points = data.points-price
    setElementData(client,"player:data",data)
    exports["cmta-db"]:dbSet("update cmta_users set skin=?, buyedskins=? where id=?",id,string.format("%s", table.concat(tableskins, ',') ),getElementData(client,"player:data").uid)
    exports['cmta-notyfikacje']:sendNotification(client,"#00ff00Sukces!\n#ffffffPomyślnie zakupiono skin ID:"..id.."\nza "..price.." punktów","success",5000,2)

    local q=exports["cmta-db"]:dbGet("select * from cmta_users where id=?", getElementData(client,"player:data").uid)   	
    triggerClientEvent(client,'cmta:przebieralnia:refresh',resourceRoot,split(q[1].buyedskins, ","))
end)

addEvent("cmta:przebieralnia:ubierz", true)
addEventHandler("cmta:przebieralnia:ubierz", resourceRoot, function(id)
    exports["cmta-db"]:dbSet("update cmta_users set skin=? where id=?",id,getElementData(client,"player:data").uid)
    setElementModel(client,id)
    exports['cmta-notyfikacje']:sendNotification(client,"#00ff00Sukces!\n#ffffffPomyślnie zmieniono skin.","success",3000,2)

    
end)



wejscie = createMarker (-2373.77515, 910.14050, 45.44531, "cylinder", 1.1, 0, 77, 0,0)
wejscielv = createMarker (2101.89282, 2257.39941, 11.02344, "cylinder", 1.1, 0, 77, 0,0)
wejsciels = createMarker (2244.32373, -1665.54980, 15.47656, "cylinder", 1.1, 0, 77, 0,0)
wyjscie = createMarker (207.65428, -111.26691, 1005.13281, "cylinder", 1.1, 0, 77, 0,0)
setElementData(wejscie, 'marker:data', {name='Wejście', icon='strzalka',size=1})
setElementData(wejscielv, 'marker:data', {name='Wejście', icon='strzalka',size=1})
setElementData(wejsciels, 'marker:data', {name='Wejście', icon='strzalka',size=1})
setElementData(wyjscie, 'marker:data', {name='Wyjście', icon='strzalka',size=1})
createBlip(-2373.77515, 910.14050, 45.44531, 45,2,0,0,0,0,0,275)
createBlip(2101.89282, 2257.39941, 11.02344, 45,2,0,0,0,0,0,275)
createBlip(2244.32373, -1665.54980, 15.47656, 45,2,0,0,0,0,0,275)






setElementDimension(wyjscie, 2000)
setElementInterior(wyjscie, 15)

addEventHandler("onMarkerHit", wejscie, function(el, md)
    if getElementType(el) ~= "player" then return end
    if isPedInVehicle(el) then return end  
    setElementDimension(el, 2000)
    setElementInterior(el, 15)
	setElementPosition(el, 207.66914, -108.75941, 1005.13281)
	setPlayerHudComponentVisible(el,"radar",false)
--	exports["PSSM-interiory"]:addloading(el,"1")
    setElementData(el,"ktoryinterior","sf")
end)

addEventHandler("onMarkerHit", wejscielv, function(el, md)
    if getElementType(el) ~= "player" then return end
    if isPedInVehicle(el) then return end  
    setElementDimension(el, 2000)
    setElementInterior(el, 15)
	setElementPosition(el, 207.66914, -108.75941, 1005.13281)
	setPlayerHudComponentVisible(el,"radar",false)
--	exports["PSSM-interiory"]:addloading(el,"1")
    setElementData(el,"ktoryinterior","lv")
end)

addEventHandler("onMarkerHit", wejsciels, function(el, md)
    if getElementType(el) ~= "player" then return end
    if isPedInVehicle(el) then return end  
    setElementDimension(el, 2000)
    setElementInterior(el, 15)
	setElementPosition(el, 207.66914, -108.75941, 1005.13281)
	setPlayerHudComponentVisible(el,"radar",false)
--	exports["PSSM-interiory"]:addloading(el,"1")
    setElementData(el,"ktoryinterior","ls")
end)

addEventHandler("onMarkerHit", wyjscie, function(el, md)
    if getElementType(el) ~= "player" then return end
	if isPedInVehicle(el) then return end	
    setElementDimension(el, 0)
    setElementInterior(el, 0)
    if getElementData(el,"ktoryinterior") == "sf" then
    setElementPosition(el, -2376.37109, 910.00598, 45.44531)
    elseif getElementData(el,"ktoryinterior") == "lv" then
    setElementPosition(el, 2104.00220, 2257.53223, 11.02344)
    else
    setElementPosition(el, 2244.90210, -1664.23035, 15.47656)
    end
--	exports["PSSM-interiory"]:addloading(el,"0")
	setPlayerHudComponentVisible(el,"radar",true)
end)